Component({
  data: {
    selected: 0,
    color: "#999999",
    selectedColor: "#7dc5eb",
    backgroundColor: "#ffffff",
    isTeacher: true, // 假设我们通过这个属性来判断用户身份
    list: [] // 初始化为空
  },
  attached() {
    this.initializeTabBar(); // 初始化导航栏
  },
  
  methods: {
    initializeTabBar() {
      const role = wx.getStorageSync('userType');
      console.log('登录角色----'+role);

      if (role=="admin") {
        this.setData({
          list: [
            {
              pagePath: "/pages/manage/index", 
              iconPath: "/image/timer.png",
              selectedIconPath: "/image/selected_timer.png",
              text: "教学管理"
            },
            {
              pagePath: "/pages/manage_service/index",
              iconPath: "/image/service.png",
              selectedIconPath: "/image/selected_service.png",
              text: "校园服务"
            }
          ]
        });
      } else if (role=="student") { 
        this.setData({
          list: [
            {
              pagePath: "/pages/news/news",
              iconPath: "/image/timer.png",
              selectedIconPath: "/image/selected_timer.png",
              text: "校园通知"
            },
            {
              pagePath: "/pages/service/index",
              iconPath: "/image/service.png",
              selectedIconPath: "/image/selected_service.png",
              text: "校园服务"
            },
            {
              pagePath: "/pages/my/index",
              iconPath: "/image/my.png",
              selectedIconPath: "/image/selected_my.png",
              text: "个人中心"
            }
          ]
        });
      }
    },

    switchTab(e) {
      const data = e.currentTarget.dataset;
      const url = data.path;
      console.log('url', url);
      wx.switchTab({ url });
    }
  }
});
